home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / jedi.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  2KB  |  82 lines

  1. /***************************************************************************
  2.  
  3.   machine.c
  4.  
  5.   Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
  6.   I/O ports)
  7.  
  8. ***************************************************************************/
  9.  
  10. #include "driver.h"
  11.  
  12. static unsigned char jedi_control_num = 0;
  13. unsigned char jedi_soundlatch;
  14. unsigned char jedi_soundacklatch;
  15. unsigned char jedi_com_stat;
  16.  
  17. WRITE_HANDLER( jedi_rom_banksel_w )
  18. {
  19.     unsigned char *RAM = memory_region(REGION_CPU1);
  20.  
  21.     if (data & 0x01) cpu_setbank (1, &RAM[0x10000]);
  22.     if (data & 0x02) cpu_setbank (1, &RAM[0x14000]);
  23.     if (data & 0x04) cpu_setbank (1, &RAM[0x18000]);
  24. }
  25.  
  26. WRITE_HANDLER( jedi_sound_reset_w )
  27. {
  28.     if (data & 1)
  29.         cpu_set_reset_line(1,CLEAR_LINE);
  30.     else
  31.         cpu_set_reset_line(1,ASSERT_LINE);
  32. }
  33.  
  34. READ_HANDLER( jedi_control_r ) {
  35.  
  36.     if (jedi_control_num == 0)
  37.         return readinputport (2);
  38.     else if (jedi_control_num == 2)
  39.         return readinputport (3);
  40.     return 0;
  41. }
  42.  
  43. WRITE_HANDLER( jedi_control_w ) {
  44.  
  45.     jedi_control_num = offset;
  46. }
  47.  
  48.  
  49. WRITE_HANDLER( jedi_soundlatch_w ) {
  50.     jedi_soundlatch = data;
  51.     jedi_com_stat |= 0x80;
  52. }
  53.  
  54. WRITE_HANDLER( jedi_soundacklatch_w ) {
  55.     jedi_soundacklatch = data;
  56.     jedi_com_stat |= 0x40;
  57. }
  58.  
  59. READ_HANDLER( jedi_soundlatch_r ) {
  60.     jedi_com_stat &= 0x7F;
  61.     return jedi_soundlatch;
  62. }
  63.  
  64. READ_HANDLER( jedi_soundacklatch_r ) {
  65.     jedi_com_stat &= 0xBF;
  66.     return jedi_soundacklatch;
  67. }
  68.  
  69. READ_HANDLER( jedi_soundstat_r ) {
  70.     return jedi_com_stat;
  71. }
  72.  
  73. READ_HANDLER( jedi_mainstat_r ) {
  74.     unsigned char d;
  75.  
  76.     d = (jedi_com_stat & 0xC0) >> 1;
  77.     d = d | (input_port_1_r(0) & 0x80);
  78.     d = d | 0x1B;
  79.     return d;
  80. }
  81.  
  82.